/**
 * 
 */
package com.guchenbo.example.gof.singleton;

/**
 * @author Cre.Gu
 *
 */
public class LazySingleton {
	private LazySingleton() {
		System.out.println("SimpleSingleton is create");
	}

	private static LazySingleton instance = null;

	public static LazySingleton getInsatnce() {
		if (instance == null)
			instance = new LazySingleton();
		return instance;
	}

	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			new Thread(new Runnable() {
				@Override
				public void run() {
					long beginTime = System.currentTimeMillis();
					for (int i = 0; i < 10000; i++) {
						LazySingleton.getInsatnce();
					}
					System.out.println(System.currentTimeMillis() - beginTime);
				}
			}).start();
		}
	}
}
